importPackage(net.sf.odinms.client);

var status = 0;
var job;
var neededitem = 4031227;
var exitmap = 109050000;

function start() {
	status = -1;
	action(1, 0, 0);
}

function action(mode, type, selection) {
	if (mode == -1) {
		cm.dispose();
	} else {
		if (mode == 0 && status == 0) {
			cm.sendOk("Make up your mind and visit me again.");
			cm.dispose();
			return;
		}
		if (mode == 1)
			status++;
		else
			status--;
		if (cm.getChar().getMapId() == 910000000) {
			if (status == 0) {
				cm.sendSimple("What do you want to do?#b\r\n#L1#I want to become a pirate!#l\r\n#L2#I want to buy pirate stuff!#l");
			} else if (status == 1) {
				if (selection == 1) {
					if (cm.getJob().equals(MapleJob.BEGINNER) && cm.getLevel() >= 10) {
						cm.sendYesNo("I knew this day would come eventually.\r\n\r\nAre you ready to become a PIRATE?");
					} else {
						cm.sendOk("Make sure you are a level 10 (or higher) beginner to become a pirate");
						cm.dispose();
					}
				} else {
					cm.sendSimple("Ok then, What do you want?\r\n#L0#Knuckler#l\r\n#L1#Guns#l\r\n#L2#Bullets#l\r\n#L3#Hat's#l\r\n#L4#Overall's#l\r\n#L5#Glove's#l\r\n#L6#Shoe's#l\r\n#L7#Scroll's#l");
					status++
				}
			} else if (status == 2) {
				cm.changeJob(MapleJob.PIRATE);
				cm.getChar().gainSp(1);
				cm.sendOk("You are now a #bPirate#k.\r\n\r\nDO NOT PRESS S, you will dc!\r\n\r\nTo up your stats, use the command #r@stats#k");
				cm.dispose();
			} else if (status == 3) {
				cm.dispose();
				if (selection == 0) {
					cm.openShop(5000);
				} else if (selection == 1) {
					cm.openShop(5001);
				} else if (selection == 2) {
					cm.openShop(5002);
				} else if (selection == 3) {
					cm.openShop(5003);
				} else if (selection == 4) {
					cm.openShop(5004);
				} else if (selection == 5) {
					cm.openShop(5005);
				} else if (selection == 6) {
					cm.openShop(5006);
				} else if (selection == 7) {
					cm.openShop(5007);
				} else {
					cm.dispose();
				}
			}
		} else {
			if (status == 0) {
				if (!cm.isLeader()) {
					cm.sendOk("Let your leader talk to me if he has 73 marbles");
				} else {
					cm.sendSimple("Hurry hurry!\r\n#L1##bI have the 73 Marbles!#l\r\n#L2#I don't have them yet!#k#l");
				}
			} else if (status == 1) {
				if (selection == 1) {
					if (cm.itemQuantity(neededitem) >= 50) {
						cm.sendYesNo("Well done! Do you want to get warped out?");
					} else {
						cm.sendOk("You don't have 50 marbles! HURRY");
						cm.dispose();
					}
				} else {
					cm.sendOk("Then why did you talk to me -.-\r\nGo on and get the marbles!!");
					cm.dispose();
				}
			} else {
				cm.warpPartyWithExpMeso(109010100, 1000000, 10000000);
				cm.gainItem(neededitem, -(cm.itemQuantity(neededitem)));
				cm.spawnMob(9400202, 100000000, 1000, 1, 1, 0, 0, 1, 0, 0);
				cm.startPartyTimer(109010100, 10000);
				cm.sendOk("I warped you to stop the timer\r\nThis special boss slime has 100mil hp!\r\nFind it, and Destroy it to receive Godly NX items!");
				cm.dispose();
			}
		}
	}
}
